import pygame
import sys
from init_map import InitMap


class Map(InitMap):
    def __init__(self, *args):
        InitMap.__init__(self)

        self.door_blue = pygame.image.load("../资源/图片/蓝门.png").convert_alpha()
        self.door_iron = pygame.image.load("../资源/图片/铁门.png").convert_alpha()
        self.key_box = pygame.image.load("../资源/图片/钥匙盒.png").convert_alpha()
        self.hp_red = pygame.image.load("../资源/图片/红药.jpg").convert_alpha()
        self.hp_blue = pygame.image.load("../资源/图片/蓝药.jpg").convert_alpha()
        self.water = pygame.image.load("../资源/图片/圣水.png").convert_alpha()
        self.dark_guard = pygame.image.load("../资源/图片/冥卫兵.png").convert_alpha()
        self.dark_soldier = pygame.image.load("../资源/图片/冥战士.png").convert_alpha()
        self.dark_leader = pygame.image.load("../资源/图片/冥队长.png").convert_alpha()
        self.ling_warrior = pygame.image.load("../资源/图片/灵武士.png").convert_alpha()
        self.senior_guard = pygame.image.load("../资源/图片/高级卫兵.png").convert_alpha()

        self.hero_pos = (5, 9)
        self.up_pos = (4, 0)
        self.down_pos = (5, 10)
        self.variable_pos = {
            (3, 0): (self.key_box, '钥匙盒'),
            (4, 9): (self.door_blue, '蓝门'),
            (6, 9): (self.door_blue, '蓝门'),
            (5, 8): (self.door_blue, '蓝门'),
            (5, 4): (self.door_iron, '铁门'),
            (2, 5): (self.hp_red, '红药'),
            (8, 5): (self.hp_red, '红药'),
            (2, 1): (self.hp_blue, '蓝药'),
            (8, 1): (self.hp_blue, '蓝药'),
            (5, 3): (self.water, '圣水'),
            (1, 9): (self.dark_guard, '冥卫兵'),
            (9, 9): (self.dark_guard, '冥卫兵'),
            (3, 9): (self.dark_guard, '冥卫兵'),
            (7, 9): (self.dark_guard, '冥卫兵'),
            (5, 7): (self.dark_soldier, '冥战士'),
            (5, 5): (self.dark_soldier, '冥战士'),
            (5, 6): (self.dark_leader, '冥队长'),
            (2, 0): (self.ling_warrior, '灵武士'),
            (2, 9): (self.senior_guard, '高级卫兵'),
            (8, 9): (self.senior_guard, '高级卫兵'),
        }

    def fixed_brick(self):
        self.draw(self.upstairs, self.up_pos[0], self.up_pos[1])
        self.dic[self.up_pos] = '上楼'
        self.draw(self.downstairs, self.down_pos[0], self.down_pos[1])
        self.dic[self.down_pos] = '下楼'
        for i in range(11):
            self.draw(self.wall, 0, i)
            self.dic[(0, i)] = '墙'
            self.draw(self.wall, 10, i)
            self.dic[(10, i)] = '墙'
            if i != 0 and i != 9:
                self.draw(self.wall, 3, i)
                self.dic[(3, i)] = '墙'
                self.draw(self.wall, 4, i)
                self.dic[(3, i)] = '墙'
                self.draw(self.wall, 6, i)
                self.dic[(3, i)] = '墙'
                self.draw(self.wall, 7, i)
                self.dic[(3, i)] = '墙'
            if not i in [0, 1, 5, 9]:
                self.draw(self.wall, 2, i)
                self.dic[(2, i)] = '墙'
                self.draw(self.wall, 8, i)
                self.dic[(8, i)] = '墙'
        for i in [(5, 1), (5, 2), (1, 10), (9, 10)]:
            self.draw(self.wall, i[0], i[1])
            self.dic[(i[0], i[1])] = '墙'
        for i in self.ls:
            self.screen.blit(self.road, i)
            self.dic[(int((i[0]-375)/48), int((i[1]-25)/48))] = '路'
